﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using Hangjing.Model;
using Hangjing.SQLServerDAL;
using Hangjing.Common;

namespace Html5
{
    public partial class mtorderlist : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            UserHelp.IsLogin_Togo(Request.Url.PathAndQuery);
            int pagesize = 8;
            int pageindex = HjNetHelper.GetQueryInt("PageNo", 1);

            PointsInfo user = UserHelp.GetUser_Togo();
            string sql = "  shopeleCustorder.delflag= 0 and  togoid=" + user.Unid+ " and SendTime > DATEADD(HOUR,-8,GETDATE()) and OrderChecker = 10 and OrderStatus < 5 ";

            new OrderState().BindOrderState(ddlstate);
            ddlstate.Items.Insert(0, new ListItem() { Value = "-1", Text = "所有" });



            string url = "eleorderlist.aspx?a=1";
            string key = HjNetHelper.GetQueryString("key");
            if (key.Length > 0)
            {
                sql += " AND (OrderComm LIKE '%" + key + "%' OR orderid LIKE '%" + key + "%')";
                url += "&key=" + key;
            }

            int state = HjNetHelper.GetQueryInt("state", -1);
            if (state >= 0)
            {
                sql += " and OrderStatus=" + state;
                url += "&state=" + state;
            }



            IList<CustorderInfo> orderlist = new shopeleCustorder().GetList(pagesize, pageindex, sql, "IsShopSet asc, OrderDateTime", 1);
            //添加支付状态 2015-11-24 
            foreach (var item in orderlist)
            {

            }

            WebUtility.BindRepeater(rptorder, orderlist);

            int countNum = new shopeleCustorder().GetCount(sql);
            int pagecount = 0;

            if (countNum % pagesize == 0)
            {
                pagecount = countNum / pagesize;
            }
            else
            {
                pagecount = countNum / pagesize + 1;
            }

            if (pagecount <= 1)
            {
                pages.Style["display"] = "none";
            }
            else
            {
                pages.InnerHtml = WebUtility.GetPageString(pageindex, pagecount, url);
            }
        }
    }
}
